/*
 * p4003.cpp
 *
 *  Created on: 2013-7-24
 *      Author: zy
 */
#include<cstdio>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<algorithm>
using namespace std;
const int maxn = 10005;
struct node
{
	int v, w;
} tmp;
vector<node> son[maxn];
int dp[maxn][15];
int n, s, m;
//dp[i][0]:派0个机器人，1个机器人访问完所有子节点回到节点i
void dfs(int u, int pa)
{
	for (int i = 0; i < son[u].size(); i++)
	{
		int v = son[u][i].v;
		int w = son[u][i].w;
		if (v == pa)
			continue;
		dfs(v, u);
		for(int j=m;j>=0;j--)
		{
			dp[u][j]=dp[u][j]+dp[v][0]+2*w;//第i颗子树排“0”个机器人
			for(int k=1;k<=j;k++)
				dp[u][j]=min(dp[u][j],dp[u][j-k]+dp[v][k]+k*w);
			//第i颗子树派k个机器人，dp[u][t]表示前i-1颗子树派t个机器人
		}
	}
}
int main()
{
	while (scanf("%d%d%d", &n, &s, &m) != EOF)
	{
		memset(dp, 0, sizeof(dp));
		for (int i = 0; i <= n; i++)
			son[i].clear();
		for (int i = 1; i < n; i++)
		{
			int x, y, w;
			scanf("%d%d%d", &x, &y, &w);
			tmp.v = y;
			tmp.w = w;
			son[x].push_back(tmp);
			tmp.v = x;
			son[y].push_back(tmp);
		}
		dfs(s, 0);
		printf("%d\n",dp[s][m]);
	}
	return 0;
}
